//
//  NormalTableViewCell.m
//  RoadKnowEntertainment
//
//  Created by lanou on 16/8/6.
//  Copyright © 2016年 RKE. All rights reserved.
//

#import "NormalTableViewCell.h"

#import "UIImageView+WebCache.h"

@interface NormalTableViewCell ()

@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *titlelabel;
@property (nonatomic, strong) UILabel *sourceLabel;
@property (nonatomic, strong) UILabel *specialLabel;

@end

@implementation NormalTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initLayout];
    }
    return  self;
    
}

- (void)initLayout {
    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, kwidth / 4, normalCellHeight - 10)];
    [self.contentView addSubview:imgView];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imgView.frame) + 5, 5, kwidth - CGRectGetWidth(imgView.frame) - 15, 40)];
    titleLabel.font = [UIFont systemFontOfSize:13];
    titleLabel.numberOfLines = 0;
    [self.contentView addSubview:titleLabel];
    
    UILabel *sourceLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(titleLabel.frame), normalCellHeight - 5 - 20, 200, 20)];
    sourceLabel.font = [UIFont systemFontOfSize:13];
    sourceLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:sourceLabel];
    
    UILabel *specialLabel = [[UILabel alloc] initWithFrame:CGRectMake(kwidth - 5 - 40, CGRectGetMinY(sourceLabel.frame), 40, 20)];
    specialLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:specialLabel];
    
    self.imgView = imgView;
    self.titlelabel = titleLabel;
    self.sourceLabel = sourceLabel;
    self.specialLabel = specialLabel;

}


- (void)setModel:(TopStoriesModel *)model {
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:model.imgsrc]];
    self.titlelabel.text = model.title;
    self.sourceLabel.text = model.source;
    if ([model.skipType  isEqual: @"special"]) {
        self.specialLabel.text = @"专题";
        self.specialLabel.backgroundColor = [UIColor redColor];
        self.specialLabel.textColor = [UIColor whiteColor];
        
        
        
    }
    
    
}

@end
